<template>
  <div class="batchList conFlex contentFlex">
    <div class="batchInfo" v-for="(item, index) in batchInfoList" :key="index">
      <div class="batchTitle conFlex contentFlex">
        <div class="titleBox">
          <span class="title">批次：</span>
          <span class="name">{{ item.productionBatchCode }}</span>
        </div>
        <div class="tagList conFlex contentFlex">
          <!-- <div class="tag blue" v-if="item.status == 'CREATE'">新创建</div>
          <div class="tag orange" v-if="item.status == 'UN_COMPLETE'">未完成</div>
          <div class="tag green" v-if="item.status == 'COMPLETED'">已完成</div> -->
          <div class="tag CREATE chooseStyle">新创建</div>
          <div class="tag UN_COMPLETE"
            :class="item.status == 'UN_COMPLETE' || item.status == 'COMPLETED' ? 'chooseStyle' : ''">未完成</div>
          <div class="tag COMPLETED" :class="item.status == 'COMPLETED' ? 'chooseStyle' : ''">已完成</div>
        </div>
      </div>
      <div class="info conFlex contentFlex">
        <div class="item">
          <span class="title">批次编号：</span>
          <span class="name">{{ item.mnecode }}</span>
        </div>
        <div class="item">
          <span class="title">养殖类型：</span>
          <span class="name">{{ item.breedTypeName }}</span>
        </div>
        <div class="item">
          <span class="title">养殖鱼塘：</span>
          <span class="name">{{ item.pondName }}</span>
        </div>
        <div class="item">
          <span class="title">养殖品种：</span>
          <span class="name">{{ item.varietyName }}</span>
        </div>
        <div class="item">
          <span class="title">鱼塘占比：</span>
          <span class="name">{{ item.pondRatio }}%</span>
        </div>
        <div class="item">
          <span class="title">创建时间：</span>
          <span class="name">{{ item.buildDateTime }}</span>
        </div>
        <div class="item">
          <span class="title">供应商：</span>
          <span class="name">{{ item.supplier ? processName(item.supplier) : '--' }}</span>
        </div>
      </div>
      <div class="btn conFlex">
        <el-button @click="queryMoreInfo(item)">查看详情</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { mymixin } from "@/utils/mixin";
export default {
  mixins: [mymixin],
  name: "BatchInfo",
  components: {},
  props: {
    batchInfoList: {
      type: [Array],
      default: () => {
        return []
      }
    }
  },

  data () {
    return {
    };
  },
  computed: {
  },
  watch: {},
  created () {
  },
  mounted () {
  },
  methods: {
    queryMoreInfo (data) {
      let routerName = ''
      switch (data.status) {
        case 'UN_COMPLETE': routerName = 'ProductionBatchQuery'
          break
        case 'CREATE': routerName = 'BatchCreate'
          break
        case 'COMPLETED': routerName = 'ProductionBatchQuery'
          break
        default: routerName = 'BatchCreate'
      }
      this.$router.push({
        name: routerName,
        params: { ...data }
      })
    }
  }
};
</script>

<style lang="scss" scoped>
.conFlex {
  display: flex;
  justify-content: flex-start;
}

.contentFlex {
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
}

.batchList {
  width: 100%;
  height: 100%;
  overflow-x: hidden;

  .batchInfo:hover {
    box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.15);
  }

  .batchInfo {
    width: calc(100%/2 - 20px);
    min-width: 300px;
    background: #ffffff;
    margin: 10px;
    padding: 15px;
    border-radius: 6px;

    .batchTitle {
      justify-content: space-between;
      height: 30px;
      line-height: 30px;
      font-size: 18px;
      font-weight: bold;
      color: #333;

      .titleBox {
        background: #03a9f4;
        padding: 0 20px;
        transform: translate(-24px, -5px);

        .title,
        .name {
          color: #ffffff;
          font-weight: 400;
        }

        .name {
          font-size: 14px;
        }
      }



      .tag {
        font-size: 12px;
        font-weight: 400;
        padding: 0 30px;
        border: 2px solid #ffffff;
        color: #fff;
        line-height: 26px;
        border-radius: 0px 15px 15px 0px;
        background: #ececec;
        cursor: pointer;
      }

      .CREATE {
        transform: translate(30px, 0);
        z-index: 1;
      }

      .UN_COMPLETE {
        transform: translate(15px, 0);
      }

      .chooseStyle {
        color: #03a9f4;
        background: #d2f1ff;
      }

    }

    .info {
      font-size: 14px;
      line-height: 28px;
      overflow-x: hidden;

      .item {
        width: 50%;
        min-width: 200px;
        color: #03a9f4;

        .title {
          color: #999;
        }
      }
    }

    .btn {
      justify-content: flex-end;
      margin-top: 10px;
    }
  }
}
</style>
